#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :comment_bilibili_cookie.py
# @Time      :2023/12/23 15:05
# @Author    :小姚

from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import json

def getCookie():
    browser = webdriver.Chrome()
    browser.get("https://www.bilibili.com")
    browser.delete_all_cookies()
    time.sleep(20)
    dictions = browser.get_cookies()
    jsons = json.dumps(dictions)

    with open("b站cookie.txt", 'w') as f:
        f.write(jsons)
    browser.quit()



if __name__ == "__main__":
    getCookie()
